package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * @EnumName ChannelExceptionEnum
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/7 11:46
 * @Version 1.0
 */
public enum ChannelExceptionEnum implements CustomExceptionCode  {
    CHANNEL_IS_EXIST(300, "名称已存在", 900),
    CHANNEL_NOT_EXIST(301, "名称不存在", 900),
    CHANNEL_SAVE_ERROE(302, "添加频道失败", 900),
    CHANNEL_DELETE_ERROE(303,"删除频道失败",900),
    CHANNEL_UPDATE_ERROE(304,"修改频道失败",900),
    CHANNEL_NOT_VOID(305,"频道信息不能为空",900),
    CHANNEL_NOT_NAME(306,"频道名称不能为空",900),
    CHANNEL_NOT_SITEID(307,"站点ID为空",900),
    CHANNEL_TEMPLETNAME_IS_EXIST(308, "别名已存在", 900),
    CHANNEL_FREEMARKER_ERRO(309, "频道模板解析失敗", 900),
    CHANNEL_TEMPLETID_NOT_NUll(310, "请选中频道模板哦", 900),
    CHANNEL_TEMPLETNAME_NOT_EXIST(311, "请给频道添加别名", 900),
    CHANNEL_TEMPLETID_NOT_EXIST(312, "频道模板不存在", 900),

    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    ChannelExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }

    public static ChannelExceptionEnum getEnumByCode(Integer code){
        for(ChannelExceptionEnum channelExceptionEnum : ChannelExceptionEnum.values()){
            if(code.equals(channelExceptionEnum.getCode())){
                return channelExceptionEnum;
            }
        }
        return null;
    }
}
